package com.xwtec.observer.v2;

/**
 * @Author: zt
 * @Date: 2021/2/28 20:56
 * 傻等，等待另外一个线程执行唤醒小孩的动作（俗称一直盯着）
 */
public class Main2 {
    public static void main(String[] args) {
        Child child = new Child();
        while (!child.isCry()){
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
        System.out.println("observing");
    }

}

class Child{
    boolean cry = false;

    public boolean isCry() {return cry;}

    //叫醒
    public void wakeUp(){
        System.out.println("wuwuwuuwu.....................");
        cry = true;
    }
}
